#! /bin/sh

if bspc query -M --names | grep "HDMI-A-0" >/dev/null 2>&1 ;then
	echo "Xft.dpi: 130" | xrdb -merge
	echo "Xcursor.size: 50" | xrdb -merge
	feh --bg-center ~/.config/feh/nord1.webp & # wallpaper
	xrandr --output HDMI-A-0 --primary
	xrandr --output eDP --right-of HDMI-A-0
	xrandr --output eDP --off
	bspc monitor HDMI-A-0 -d 1 2 3 4 5 6 7 8 9 10
else
	echo "Xft.dpi: 210" | xrdb -merge
	echo "Xcursor.size: 70" | xrdb -merge
	feh --bg-center ~/.config/feh/nord1.webp &
	bspc monitor -d 1 2 3 4 5 6 7 8 9 10
fi

bspc config border_width         6
bspc config focused_border_color "#8FBCBB"
bspc config normal_border_color "#81A1C1"
bspc config window_gap          19
bspc config split_ratio          0.52
bspc config borderless_monocle   true
bspc config gapless_monocle      true
bspc config focus_follows_pointer	true

bspc rule -a "TelegramDesktop" state=floating center=on rectangle=1200x1200+0+0
bspc rule -a "Clash for Windows" state=floating center=on rectangle=2000x1200+0+0
bspc rule -a "miniTerminal" state=floating center=on rectangle=800x800+0+0
bspc rule -a "nmtui" state=floating center=on rectangle=800x800+0+0
bspc rule -a "CopyQ" state=floating center=on rectangle=800x800+0+0

pgrep -x sxhkd > /dev/null || sxhkd &
picom -b &
fcitx5 &

if bspc query -M --names | grep "HDMI-A-0" >/dev/null 2>&1 ; then
  ~/.config/polybar/launch.sh monitor
else
  ~/.config/polybar/launch.sh note
fi

/opt/clash-for-windows-bin/cfw
